package com.example.administrator.yuejian_15.fragment;


import android.app.Fragment;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


import com.example.administrator.yuejian_15.R;
import com.example.administrator.yuejian_15.adapter.JlbAdapter;
import com.example.administrator.yuejian_15.bean.JlbBean;
import com.example.administrator.yuejian_15.listener.ListListener;
import com.example.administrator.yuejian_15.model.JlbModel;

import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class JlbFragment extends BaseFragment {

    RecyclerView rv_jlb;
    List<JlbBean> items;


    @Override
    void initView() {
        rv_jlb = (RecyclerView)view.findViewById(R.id.rv_jlb);
        JlbModel jlbModel = new JlbModel();
        jlbModel.getJlbInfo(jlbBeanListListener);

    }

    ListListener<JlbBean> jlbBeanListListener= new ListListener<JlbBean>() {
        @Override
        public void onResponse(List<JlbBean> list) {
            LinearLayoutManager linearLayoutManager=new LinearLayoutManager(getActivity());
            linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
            rv_jlb.setLayoutManager(linearLayoutManager);
            items=list;
            JlbAdapter jlbAdapter=new JlbAdapter(getContext(),items,R.layout.item);
            rv_jlb.setAdapter(jlbAdapter);
            rv_jlb.setItemAnimator(new DefaultItemAnimator());
        }

        @Override
        public void onFail(String msg) {

        }
    };

    @Override
    void initEvent() {

    }

    @Override
    void initDate() {

    }

    public JlbFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        setLayout_file(R.layout.fragment_jlb );
        return super.onCreateView(inflater,container,savedInstanceState);
    }

}
